<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="net.sureon.web.system.CustomerForm"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/AdminTemplet.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>客户信息</title>
<script type="text/javascript">
	function validateForm(myForm) {
		if(myForm.companyFullName.value == "") {
			alert("公司全称必填");
			return false;
		}
		if(myForm.siteURL.value == "") {
			alert('公司简称必填');
			return false;		
		}
		if(myForm.companyWebSite.value == "") {
			alert('公司网址必填');
			return false;
		}
		if(myForm.companyAddress.value == "") {
			alert('公司地址必填');
			return false;
		}
		if(myForm.hrName.value == "") {
			alert('考勤负责人姓名必填');
			return false;
		}
		if(myForm.hrEmail.value == "") {
			alert('考勤负责人邮箱必填');
			return false;
		} else {
			var re = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
			if (!re.test(myform.hrEmail.value)) {
				alert("邮箱格式不正确， 请正确填写");
				return false;
			}
		}
		if(isNaN(myForm.hrTel)) {
			alert('电话号码应该为0-9的数字');
			return false;
		}
		if(myForm.hrAddress.value == "") {
			alert('考勤负责人住址必填');
			return false;
		}
		if(myForm.adminName.value == "") {
			alert('管理员姓名必填');
			return false;
		}	
		if(myForm.adminEmail.value == "") {
			alert('管理员电子邮箱必填');
			return false;
		} else {
			var re = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
			if (!re.test(myform.adminEmail.value)) {
				alert("邮箱格式不正确， 请正确填写");
				return false;
			}
		}
		if(myForm.adminAddress.value == "") {
			alert('管理员通信地址必填');
			return false;
		}
		if(myForm.registerDate.value == "") {
			alert('启用日期必填');
			return false;
		}
		if(myForm.validDate.value == "") {
			alert('有效日期必填');
			return false;
		}
		return true;
	}
</script>
</head>

<body>
<jsp:include page="systemHeader.jsp" />
<%
	String view = request.getParameter("view");
 %>
<table cellpadding="0" cellspacing="0" class="style5">
	<tr>
		<td colspan="2">
		<table cellpadding="0" cellspacing="0" class="style5">
			<tr>
				<td style="text-align: left" bgcolor="#FFFBD6" class="style6">
				<table id="ctl00_ContentPlaceHolder1_Menu1"
					class="ctl00_ContentPlaceHolder1_Menu1_2" cellpadding="0"
					cellspacing="0" border="0">
					<tr>
						<td onmouseover="Menu_HoverStatic(this)"
							onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)"
							id="ctl00_ContentPlaceHolder1_Menu1n0">
						<table 						
<%
	if(!"customer".equals(view)) {
 %>
class="ctl00_ContentPlaceHolder1_Menu1_4 ctl00_ContentPlaceHolder1_Menu1_9"
<%
	}
 %>
							cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td style="white-space: nowrap;"><a
									class="ctl00_ContentPlaceHolder1_Menu1_1 ctl00_ContentPlaceHolder1_Menu1_3 ctl00_ContentPlaceHolder1_Menu1_8"
									href="<%=request.getContextPath() %>/sysAdmin/manageCustomer.do?view=potential">潜在客户</a></td>
							</tr>
						</table>
						</td>
						<td style="width: 3px;"></td>
						<td onmouseover="Menu_HoverStatic(this)"
							onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)"
							id="ctl00_ContentPlaceHolder1_Menu1n1">
						<table cellpadding="0"
							cellspacing="0" border="0" width="100%"
<%
	if("customer".equals(view)) {
 %>
class="ctl00_ContentPlaceHolder1_Menu1_4 ctl00_ContentPlaceHolder1_Menu1_9"
<%
	}
 %>
>
							<tr>
								<td style="white-space: nowrap;"><a
									class="ctl00_ContentPlaceHolder1_Menu1_1 ctl00_ContentPlaceHolder1_Menu1_3"
									href="<%=request.getContextPath() %>/sysAdmin/manageCustomer.do?view=customer">客户信息</a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td colspan="2">
								<div align="center">
									<!-- InstanceBeginEditable name="EditRegion3" -->

									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td colspan="3">
												<div align="left">
													<table width="100%" border="0" cellpadding="4"
														cellspacing="0" bordercolor="#0000FF"
														style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
														<tr style="color: White; background-color: #507CD1; font-weight: bold;" align="center">
															<th scope="col">公司全称</th>
															<th scope="col">公司英文简写</th>
															<th scope="col">公司网址</th>
															<th scope="col">公司地址</th>
															<th scope="col">管理员</th>
															<th scope="col">管理员电话</th>
															<th scope="col">销售代表</th>
															<th scope="col">启用日期</th>
															<th scope="col">停用日期</th>
														</tr>
														<c:forEach var="customer" items="${customers}"
															varStatus="rowCounter">
															<c:choose>
																<c:when test="${rowCounter.count % 2 == 0}">
																	<c:set var="bgColor" scope="page" value="#EFF3FB;" />
																</c:when>
																<c:otherwise>
																	<c:set var="bgColor" scope="page" value="#FFFFFF;" />
																</c:otherwise>
															</c:choose>
															<tr  style="background-color: ${bgColor}"  align="center">
																<td>
																	<a
																		href="manageCustomer.do?action=edit&customerID=${customer.companyID}&view=${customerForm.view }">${customer.companyVO.companyFullName
																		}</a>
																</td>
																<td>
																	<a
																		href="jump.do?companyID=${customer.companyID}" title="jump to the company as company admin">${customer.companyVO.siteURL}</a>
																</td>
																<td>
																	${customer.companyVO.companyWebSite }
																</td>
																<td>
																	${customer.companyVO.companyAddress }
																</td>
																<td>
																	${customer.companyVO.adminName }
																</td>
																<td>
																	${customer.companyVO.adminTel }
																</td>

																<td>
																	<c:choose>
																		<c:when test="${customer.companyVO.seller == '-1'}">
																			&nbsp;&nbsp;
																		</c:when>
																		<c:otherwise>
																			${customer.companyVO.seller }
																		</c:otherwise>
																	</c:choose>
																</td>
																<td>
																	<fmt:formatDate
																		value="${customer.companyVO.registerDate}"
																		pattern="yyyy-MM-dd" />
																</td>
																<td>
																	<fmt:formatDate value="${customer.companyVO.validDate}"
																		pattern="yyyy-MM-dd" />
																</td>
															</tr>
														</c:forEach>

													</table>
												</div>
											</td>
										</tr>
										<form:form id="customerForm" name="customerForm"
											commandName="customerForm" onsubmit="return validateForm(this);">
											<tr>
												<td>
													&nbsp;
												</td>
												<td>
													<label></label>
													<div align="center"></div>
												</td>

												<td>
													&nbsp;
												</td>
											</tr>
											<tr>
												<td colspan="3">
													<hr />
												</td>
											</tr>
											<tr>
												<td colspan="3">
													&nbsp;
												</td>
											</tr>
											<tr>

												<td colspan="3">
													<div align="center">
														<table align="center" cellpadding="0" cellspacing="0" style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
															<tr>
																<td width="175">
																	<div align="right">
																		公司全称(*)：
																	</div>
																</td>
																<td width="175">
																	<div align="left">
																		<form:input path="companyFullName"
																			cssStyle="height: 16px; width: 200px;" />

																	</div>
																</td>
																<td width="79">
																	&nbsp;
																</td>

																<td width="70">
																	&nbsp;
																</td>
																<td width="175">
																	<div align="right">
																		考勤负责人姓名(*)：
																	</div>
																</td>
																<td width="175">
																	<div align="left">
																		<form:input path="hrName"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		公司英文简写(*)：
																	</div>
																</td>

																<td>
																	<div align="left">
																		<form:input path="siteURL"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		考勤负责人电子邮箱(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="hrEmail"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		公司网址(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="companyWebSite"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>

																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		考勤负责人电话：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="hrTel"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		公司地址(*)：
																	</div>
																</td>

																<td>
																	<div align="left">
																		<form:input path="companyAddress"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		考勤负责人传真：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="hrFax"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		邮政编码：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="companyZipCode"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>

																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		考勤负责人通信地址(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="hrAddress"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		所属行业：
																	</div>
																</td>

																<td>
																	<div align="left">
																		<form:input path="industry"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		管理员姓名(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="adminName"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		员工人数：
																	</div>
																</td>
																<td>
																	<div align="left">																	
																	<form:input path="employeeNum"
																			cssStyle="height: 16px; width: 100px;" disabled="true"/>
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>

																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		管理员电子邮箱(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="adminEmail"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		公司类型：
																	</div>
																</td>

																<td>
																	<div align="left">
																		<form:select path="companyType"
																			cssStyle="height: 23px; width: 200px;">
																			<form:option value="-1" label="--请选择--" />
																			<form:options items="${customerForm.companyTypeList}"
																				itemValue="typeShortName" itemLabel="typeFullName" />
																		</form:select>
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>

																<td>
																	<div align="right">
																		管理员电话：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="adminTel"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		客户状态：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:select path="companyStatus"
																			cssStyle="height: 23px; width: 200px;">
																			<form:option value="-1" label="--请选择--" />
																			<form:options
																				items="${customerForm.companyStatusList}"
																				itemValue="statusValue"
																				itemLabel="statusDisplayName" />
																		</form:select>
																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		管理员传真：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="adminFax"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>

															</tr>
															<tr>
																<td>
																	<div align="right">
																		销售代表：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="seller"
																			cssStyle="height: 23px; width: 200px;"/>

																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		管理员通信地址(*)：
																	</div>
																</td>

																<td>
																	<div align="left">
																		<form:input path="adminAddress"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<tr>
																<td>
																	<div align="right">
																		注册日期(*)：
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="registerDate"
																			cssStyle="height: 16px; width: 200px;" />

																	</div>
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	&nbsp;
																</td>
																<td>
																	<div align="right">
																		有效日期(*):
																	</div>
																</td>
																<td>
																	<div align="left">
																		<form:input path="validDate"
																			cssStyle="height: 16px; width: 200px;" />
																	</div>
																</td>
															</tr>
															<c:if test='${customerForm.view != null}'>
																<form:hidden path="view" />
															</c:if>

															<form:hidden path="companyID" />
															<tr>
																<td colspan="6">
																	<div align="center">
																		<input type="submit" name="Submit"
																			value="<c:choose><c:when test='${customerForm.companyID > 0}'>更新客户</c:when><c:otherwise>创建客户</c:otherwise></c:choose>" />
																		&nbsp;&nbsp;
																		<input type="button" name="clear" value="清空表格"
																			id="clear"
																			onClick="location.href='manageCustomer.do'" />
																	</div>
																</td>
															</tr>
															</form:form>
														</table>
													</div>
													<div align="center"></div>
												</td>

											</tr>
									</table>
									<!-- InstanceEndEditable -->
								</div>
							</td>
						</tr>
					</table></body>
<!-- InstanceEnd --></html>
